﻿using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Babylon.Primitives
{
    /// <summary>
    /// Vertex structure with texture coordinates
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct VertexPositionNormalTexture : IPositionNormalTexture
    {
        private Vector3 _position;
        private Vector3 _normal;
        private Vector2 _texCoords;

        /// <summary>
        /// Get or set the position
        /// </summary>
        public Vector3 Position { get { return _position; } set { _position = value; } }

        /// <summary>
        /// Get or set the normal
        /// </summary>
        public Vector3 Normal { get { return _normal; } set { _normal = value; } }

        /// <summary>
        /// Get or set the texture coordinates
        /// </summary>
        public Vector2 TexCoords { get { return _texCoords; } set { _texCoords = value; } }

        static VertexDeclaration _vertexDeclaration = new VertexDeclaration(
            new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
            new VertexElement(3 * sizeof(float), VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
            new VertexElement(6 * sizeof(float), VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0));


        public static VertexDeclaration GetVertexDeclaration()
        {
            return _vertexDeclaration;
        }
    }
}
